<template>
<!-- //:rules="rules" -->
    <el-form :model="ruleForm" :rules="rules"  ref="ruleForm" label-width="100px" class="demo-ruleForm">
  <el-form-item label="活动编号" >
    <el-input v-model="ruleForm.activity_id" readonly></el-input>
  </el-form-item>
<!-- 
  <el-form-item label="活动类型名" prop="activity_type_name">  
  <el-input v-model="ruleForm.activity_type_name"></el-input>
  </el-form-item> -->

  <el-form-item label="活动类型名" prop="activity_type_name">
    <!-- <el-input v-model="ruleForm.activity_type_name"></el-input> -->
      <el-select v-model="ruleForm.activity_type_name" placeholder="请选择活动类型名">
      <el-option label="公益" value="公益" ></el-option>
      <el-option label="辩论赛" value="辩论赛"></el-option>
      <el-option label="讲座" value="讲座"></el-option>
      <el-option label="体育竞赛" value="体育竞赛"></el-option>
      <el-option label="宣传" value="宣传" ></el-option>
      <el-option label="影视" value="影视"></el-option>
    </el-select>
  </el-form-item>

  <el-form-item label="活动名字" >
    <el-input v-model="ruleForm.activity_name" readonly></el-input>
  </el-form-item>
 <el-form-item label="活动描述" prop="activity_description">
    <el-input v-model="ruleForm.activity_description" ></el-input>
  </el-form-item>
  <el-form-item label="活动开始时间" prop="activity_start_time">
    <el-input v-model="ruleForm.activity_start_time"></el-input>
  </el-form-item>
  <!-- <el-form-item label="活动结束时间" prop="activity_end_time">
    <el-input v-model="ruleForm.activity_end_time"></el-input>
  </el-form-item> -->
  <el-form-item label="活动结束时间">
<el-date-picker
      v-model="ruleForm.activity_end_time"
      type="datetime"
      format="yyyy-MM-dd HH:mm:ss"
      value-format="yyyy-MM-dd HH:mm:ss"
      placeholder="选择时间">
    </el-date-picker>
  </el-form-item>
   
 <el-form-item label="活动报名开始时间" prop="signup_start_time">
    <el-input v-model="ruleForm.signup_start_time" ></el-input>
  </el-form-item>
  <el-form-item label="活动报名结束时间" prop="signup_end_time">
    <el-input v-model="ruleForm.signup_end_time"></el-input>
  </el-form-item>
  <!-- <el-form-item label="时间年" prop="times">
    <el-input v-model="ruleForm.times" ></el-input>
  </el-form-item> -->
  <el-form-item label="活动地点x坐标" prop="x_coordinate">
    <el-input v-model="ruleForm.x_coordinate"></el-input>
  </el-form-item>
  <el-form-item label="活动地点y坐标" prop="y_coordinate">
    <el-input v-model="ruleForm.y_coordinate"></el-input>
  </el-form-item>
  <el-form-item label="活动地点" prop="activity_place">
    <el-input v-model="ruleForm.activity_place"></el-input>
  </el-form-item>
<!-- 
<el-form-item label="openid" prop="openid">
    <el-input v-model="ruleForm.openid"></el-input>
  </el-form-item>
  <el-form-item label="邮箱" prop="contactEmail">
    <el-input v-model="ruleForm.contactEmail"></el-input>
  </el-form-item>
   <el-form-item label="联系人" prop="contactName">
    <el-input v-model="ruleForm.contactName"></el-input>
  </el-form-item>
  <el-form-item label="联系人电话" prop="contactNum">
    <el-input v-model="ruleForm.contactNum"></el-input>
  </el-form-item>
 <el-form-item label="创建者id" prop="create_user_id">
    <el-input v-model="ruleForm.create_user_id"></el-input>
  </el-form-item>
  <el-form-item label="创建者姓名" prop="create_user_name">
    <el-input v-model="ruleForm.create_user_name"></el-input>
  </el-form-item>
  <el-form-item label="计划人数" prop="plan_num">
    <el-input v-model="ruleForm.plan_num"></el-input>
  </el-form-item> -->

  <el-form-item>
    <el-button type="primary" @click="submitForm('ruleForm')">修改</el-button>
    <el-button @click="resetForm('ruleForm')">重置</el-button>
  </el-form-item>
</el-form>
</template>
<script>
  export default {
    data() {
      return {
        ruleForm: {
            activity_id: '',
            activity_type_name:'',
            activity_name: '',
            activity_description:'',
            activity_start_time: '',
            activity_end_time: '',
            signup_start_time: '',
            signup_end_time: '',
            x_coordinate: '',
            y_coordinate: '',
            activity_place: '',
            // openid:'',
            // contactEmail:'',
            // contactName:'',
            // contactNum:'',
            // create_user_id:'',
            // create_user_name:'',
            // plan_num:'',
        },
        rules: {
          // activity_type_name: [
          //   { required: true, message: '请输入活动类型名', trigger: 'blur' },
          //   { min: 0, max: 8, message: '长度在 0 到 5 个字符', trigger: 'blur' }
          // ],
            
        
            
          
        
        }
      };
    },
    methods: {
      submitForm(formName) {
          const _this=this
          var qs=require('qs')
        //  _this.$router.push('/notices')
        this.$refs[formName].validate((valid) => {
           // console.log(12)
          if (valid) {
                console.log('15'+this.ruleForm.activity_type_name)
               axios({
            method:"put",
            url:"http://localhost:8085/tb-activityinfo/web/updateActivityInfo",
           // data:qs.stringify(this.ruleForm),
           params:this.ruleForm,
           headers:{'Content-Type':'application/x-www-form-urlencoded'}
        }).then(function (resp){
            console.log(15)
              if(resp.data.data.msg=='活动信息修改成功'){
                  _this.$alert('《'+_this.ruleForm.activity_id+'》修改成功！', '消息', {
          confirmButtonText: '确定',
          callback: action => {
               _this.$router.push('/activityinfo')
          }  
        });
          }
          
        })
           
           
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    },
    created(){
       //alert( this.$route.query.activity_id)
         const _this=this
        axios({
           
            method:"post",
            url:"http://localhost:8085/tb-activityinfo/web/selectByActivityInfoId",
            params:{activity_id:this.$route.query.activity_id},
            data:{},
           
            
        }).then(function (resp){
            console.log('12'+resp.data.data.tbActivityInfo.activity_type_name)
            _this.ruleForm=resp.data.data.tbActivityInfo
            
        })
    }
  }
</script>